package com.lx.serv.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.lx.dao.CoachDao;
import com.lx.domain.coach;
import com.lx.serv.CoachServ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CoachServImpl implements CoachServ {
    @Autowired
    CoachDao coachDao;

    @Override
    public List<coach> getAll() {
        return coachDao.selectList(null);
    }

    @Override
    public boolean add(coach coa) {
        return coachDao.insert(coa) > 0;
    }

    @Override
    public boolean update(coach coa) {
        LambdaUpdateWrapper<coach> lqw = new LambdaUpdateWrapper<coach>();
        lqw.eq(coach::getId, coa.getId());
        return coachDao.update(coa, lqw) > 0;
    }

    @Override
    public boolean delete(int id) {
        return coachDao.deleteById(id) > 0;
    }
}
